Documentation for sales/create.blade.php & SalesController.php
The Sales Creation form is a dynamic interface designed for recording sales transactions. It supports
direct sales (bypassing purchase stock) or store-based sales. The visibility of fields like
Barcode, VAT, SD, and Warranty is toggled via the Sales Form Settings.
$form_settings (SalesFormSetting model) to hide/show columns based on business
requirements.
The top section captures metadata for the transaction:
_is_direct_sales: Choice between "Store Sales" (stock based) or "Direct Sales".
_main_ledger_id. Displays Customer Name, Phone, and
Address automatically.
The heart of the form where items are added. Users can add multiple rows.
| Field Name | Functionality |
|---|---|
_search_item_id |
Search item by name or barcode. Triggers item-sales-barcode-search. |
_qty |
Sales quantity. System triggers stock validation on keyup. |
_sales_rate |
Pre-fetched from price list but editable for custom pricing. |
_vat / _sd |
Percentage-based calculations for Value Added Tax and Supplementary Duty. |
_value |
Calculated as (Qty * Rate) + VAT + SD - Discount. |
Barcode Support: If enabled, users can scan unique barcodes which automatically populate row details.
Depending on the user's account type, the form loads different sub-views:
create_acc_cb.blade.php: Optimized for Cash/Bank transactions.create_acc_detail.blade.php: Full ledger entry for credit sales.SalesAccount:
Account Receivable (Customer)
Sales Income
DB::beginTransaction(). If any step fails, the entire sale is
rolled back.
sales table entry with _sub_total, _total_vat,
and _total.
ProductPriceList qty, and records movement in
ItemInventory.
account_data_save() to update ledger balances and reporting tables.
The bottom section handles final calculations and saving:
sales/print/{id} immediately.